# 方案1
# from fastapi import Depends, FastAPI
# import uvicorn
#
# docs_url=None: 代表关闭SwaggerUi
# redoc_url=None: 代表关闭redoc文档
# app = FastAPI(docs_url=None, redoc_url=None)
# app = FastAPI()
#
#
# @app.get("/")
# async def index():
#     """
#     注册一个根路径
#     ：return
#     """
#     return {"message": "Hello World."}
#
#
# @app.get("/info")
# async def info():
#     """
#     项目信息
#     : return
#     """
#     return {
#         "app_name":"FastAPI框架学习",
#         "app_version": "v0.0.1"
#     }
#
#
# if __name__=="__main__":
#     uvicorn.run(app, host="127.0.1.0", port=8000)


# 方案2
import uvicorn
from fastapi import Depends, FastAPI
from app.controller import RegisterRouterList
from app import errors, middleware

app = FastAPI()

for item in RegisterRouterList:
    app.include_router(item.router)


if __name__ == "__main__":
    uvicorn.run(app,host="127.0.0.1", port=8000)


"""
from app import errors, middleware


# 实例化
server = FastAPI(redoc_url=None, docs_url="/apidoc", title="FastAPI学习")

# 注册中间件
middleware.registerMiddlewareHandle(server)


# 方案3
import uvicorn
from fastapi import Depends, FastAPI
from app import bootstrap
from app.config import globalAppSettings

if __name__ == "__main__":
    print("打印项目配置:", globalAppSettings)
    # 实例化
    server = FastAPI(redoc_url=None, docs_url="/apidoc", title=globalAppSettings.app_name)
    # 初始化项目
    bootstrap.Init(server)
    # 使用 python main.py 启动服务
    uvicorn.run(server, host=globalAppSettings.app_host, port=globalAppSettings.app_port)
"""
